﻿
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.11.2.min.js" type="text/javascript"></script>


    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/JqueryPlug/dtGrid/jquery.dtGrid.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <script src="/Scripts/city.js"></script>
    <script type="text/javascript">
        var branchNo = ComFunJS.getQueryString("branchNo");
        var model = avalon.define({
            $id: "BranchAdd",
            RoleData: { DeptName: "", DeptDesc: "", DeptShort: "" },
            BranchAdd: function () {
                var branchName = $("#branchName").val();
                var branchDesc = $("#branchDesc").val();
                var branchShort = $("#branchShort").val();
                if ($.trim(branchName) == "") {
                    ComFunJS.winwarning("请输入部门名称");
                    return;
                }
                if ($.trim(branchDesc) == "") {
                    ComFunJS.winwarning("请输入部门描述");
                    return;
                }
                var reg = /^\d+$/;
                if ($.trim(branchShort) == "") {
                    ComFunJS.winwarning("请输入部门排序");
                    return;
                }
                if (!reg.test(branchShort)) {
                    ComFunJS.winwarning("排序必须为数字");
                    return;
                }
                var modelValue = JSON.stringify(model.RoleData.$model);
                $.post("/API/SZHLAPI.ashx", { Action: "ADDBRANCH", P1: modelValue },
                function (result) {
                    if ($.trim(result.ErrorMsg) != "") {
                        ComFunJS.winwarning(result.ErrorMsg);
                    }
                });
            },
            SetFrameHeight: function (framename) {
                var oFrm = document.getElementById(framename);
                oFrm.onload = oFrm.onreadystatechange = function () {
                    if (this.readyState && this.readyState != 'complete') return;
                    else {
                        var mainheight = $("#dvContent").height() - 45;
                        $("#" + framename).height(mainheight);
                        $("#mastmenu").height(mainheight);
                        $(window.frames[framename].document).find(".maindiv").css({ height: mainheight + "px", overflow: "auto" });
                    }
                }
            }
        });

        if (branchNo != null) {
            avalon.ready(function () {
                //获取主要菜单
                $.getJSON('/API/SZHLAPI.ashx?Action=GETBRANCHBYCODE', { "P1": branchNo }, function (resultData) {
                    model.RoleData = resultData.Result;
                })
            })
        }
    </script>
</head>
<body ms-controller="BranchAdd">
    <div class="container-fluid maindiv  text-center" style="margin: 20px 20px 50px 20px">
        <div class="form-horizontal">
            <div class="form-group">
                <label for="branchName" class="col-xs-4 control-label text-right">部门名称</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" id="branchName" ms-duplex="RoleData.DeptName" placeholder="请输入部门名称" />
                </div>
            </div>

            <div class="form-group">
                <label for="branchDesc" class="col-xs-4 control-label text-right">部门描述</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="RoleData.DeptDesc" id="branchDesc" placeholder="请输入部门描述" />
                </div>
            </div>
            <div class="form-group">
                <label for="branchShort" class="col-xs-4 control-label text-right">排序</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="RoleData.DeptShort" id="branchShort" placeholder="请输入部门排序" />
                </div>
            </div>
            <div class="form-group  ">
                <div class="col-xs-12 text-center ">
                    <input type="button" id="btnAdd" value="保存" ms-click="BranchAdd()" class="btn btn-lg btn-success" />
                </div>
            </div>
        </div>

    </div>
</body>
</html>
